﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;

namespace GameWP
{
    public class MemberScreen : GameScreen
    {
#region Properties
        private Texture2D _background;
        public Texture2D Background
        {
            get { return _background; }
            set { _background = value; }
        }

        private MemberComponent _memberComponent;
#endregion

#region  Initilation
        public MemberScreen(Game game, MainGame mainGame, SpriteBatch spriteBatch, 
            Texture2D background, Texture2D startGame, SpriteFont menuFont, SpriteFont textFont, List<Texture2D> listIconAHero)
            : base(game, mainGame, spriteBatch)
        {
            _game = game;
            _mainGame = mainGame;
            _spriteBatch = spriteBatch;
            _background = background;

            // Init component
            _memberComponent = new MemberComponent(_game, menuFont, textFont, startGame, listIconAHero, _spriteBatch);
            Components.Add(_memberComponent);
                // Tao event bat button memberComponent touch
            for (int i = 0; i < _memberComponent.ListItemMenu.Count; i++)
                _memberComponent.ListItemMenu[i].Selected += new Button.IsSelected(ItemMenu_Selected);
        }
        
#endregion
          
#region Methods
        void ItemMenu_Selected(int input)
        {
            switch (input)
            {
                case 0: _mainGame.ShowScreen(3); break;
                case 1: _mainGame.ShowScreen(5); 
                    if (ManagerGame.SoundOn)
                        ManagerGame.managerSound._newScreen.Play();  
                        break;
            }
        }    
#endregion

#region Update & Draw
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            _spriteBatch.Begin();
            _spriteBatch.Draw(_background, Vector2.Zero, Color.White);
            base.Draw(gameTime);
            _spriteBatch.End();
        }
#endregion
    }
}
